<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Relation Inferences</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Relation Inferences' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">knowledge</a></li><li><a href="index.html#5">Chapter 5: Modelling</a></li><li><b>Relation Inferences</b></li></ul></div>
<p class="purpose">Inferences that a relation holds between two subjects or values.</p>

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>Relation inferences are made about a relation, and say that two other
subjects or values are related by it. Thus, if Charles "knows" Sebastian,
this fact is an inference about the knowledge relation, not about either
Charles or Sebastian, who are only the terms listed in its data.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">inference_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::start</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">RelationInferences::start</span></span>:<br/>Knowledge Module - <a href="1-km.html#SP3">&#167;3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax"> = </span><a href="5-inf.html#SP10" class="function-link"><span class="function-syntax">Inferences::new_family</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">I</span><span class="string-syntax">"relation_inf"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax">, </span><span class="constant-syntax">LOG_DETAILS_INF_MTID</span><span class="plain-syntax">, </span><a href="5-ri.html#SP5" class="function-link"><span class="function-syntax">RelationInferences::log_details</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax">, </span><span class="constant-syntax">COMPARE_INF_MTID</span><span class="plain-syntax">, </span><a href="5-ri.html#SP6" class="function-link"><span class="function-syntax">RelationInferences::cmp</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b>Terms can be given either as subjects or as arbitrary values. This was a late
change to Inform, which came in with dynamic relations between (say) numbers,
and therefore the need to set up an initial state for those relations.
</p>

<p class="commentary">The terms will either both be subjects, or both be values, so at all times
exactly one of these pairs of pointers is <span class="extract"><span class="extract-syntax">NULL</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">terms_as_subjects</span><span class="plain-syntax">[2];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">terms_as_values</span><span class="plain-syntax">[2];</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="function-syntax">RelationInferences::new</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">RelationInferences::new</span></span>:<br/><a href="5-ri.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subj0</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subj1</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val0</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="constant-syntax">PROTECTED_MODEL_PROCEDURE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[0] = </span><a href="4-is.html#SP9" class="function-link"><span class="function-syntax">InferenceSubjects::divert</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subj0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[1] = </span><a href="4-is.html#SP9" class="function-link"><span class="function-syntax">InferenceSubjects::divert</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subj1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">val0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[1] = </span><span class="identifier-syntax">val1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><a href="5-inf.html#SP2" class="function-link"><span class="function-syntax">Inferences::create_inference</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">STORE_POINTER_relation_inference_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">data</span><span class="plain-syntax">), </span><span class="identifier-syntax">prevailing_mood</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<ul class="endnotetexts"><li>The structure relation_inference_data is private to this section.</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. </b>As promised, these are drawn using either subjects or values, but not both:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::draw</span><span class="plain-syntax">(</span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subj0</span><span class="plain-syntax">, </span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">subj1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><a href="5-ri.html#SP3" class="function-link"><span class="function-syntax">RelationInferences::new</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">subj0</span><span class="plain-syntax">, </span><span class="identifier-syntax">subj1</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-inf.html#SP8" class="function-link"><span class="function-syntax">Inferences::join_inference</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><a href="4-rs.html#SP1" class="function-link"><span class="function-syntax">RelationSubjects::from_bp</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">bp</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::draw_spec</span><span class="plain-syntax">(</span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val0</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">val1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">val0</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"malformed value relation"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><a href="5-ri.html#SP3" class="function-link"><span class="function-syntax">RelationInferences::new</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">val0</span><span class="plain-syntax">, </span><span class="identifier-syntax">val1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><a href="5-inf.html#SP8" class="function-link"><span class="function-syntax">Inferences::join_inference</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><a href="4-rs.html#SP1" class="function-link"><span class="function-syntax">RelationSubjects::from_bp</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">bp</span><span class="plain-syntax">));</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>And here are the method calls:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::log_details</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">RelationInferences::log_details</span></span>:<br/><a href="5-ri.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inference_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">f</span><span class="plain-syntax">, </span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">inf</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_relation_inference_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">inf</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">data</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[0]) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"-1:$j"</span><span class="plain-syntax">, </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[1]) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"-2:$j"</span><span class="plain-syntax">, </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[0]) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"-s1:$P"</span><span class="plain-syntax">, </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[1]) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"-s2:$P"</span><span class="plain-syntax">, </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. </b>Note that the topic of a relation inference depends on both terms. If
Charles knows Sebastian and Charles also knows Julia, then these two inferences
both belong to the knowledge relation, but "differ in topic", so that there
is no contradiction. If in fact the knowledge relation wants to make this a
one-to-one relationship, it will have to detect the contradiction of Charles
knowing both of them elsewhere: the inference machinery can't do so for it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::cmp</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">RelationInferences::cmp</span></span>:<br/><a href="5-ri.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inference_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">f</span><span class="plain-syntax">, </span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">i1</span><span class="plain-syntax">, </span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">i2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_relation_inference_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">i1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">data</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_relation_inference_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">i2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">data</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_infs</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[1]) -</span>
<span class="plain-syntax">            </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_infs</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -</span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_infs</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[0]) -</span>
<span class="plain-syntax">        </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_infs</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -</span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_pn</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[1]) -</span>
<span class="plain-syntax">        </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_pn</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -</span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_pn</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data1</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[0]) -</span>
<span class="plain-syntax">        </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_pn</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">data2</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -</span><span class="constant-syntax">CI_DIFFER_IN_TOPIC</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_inf</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">i1</span><span class="plain-syntax">) - </span><a href="5-inf.html#SP7" class="function-link"><span class="function-syntax">Inferences::measure_inf</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">i2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">CI_DIFFER_IN_COPY_ONLY</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">c</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> -</span><span class="constant-syntax">CI_DIFFER_IN_COPY_ONLY</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">CI_IDENTICAL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. </b>And finally two access functions:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::get_term_subjects</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">RelationInferences::get_term_subjects</span></span>:<br/>Relation Subjects - <a href="4-rs.html#SP3">&#167;3</a><br/>The Model World - <a href="5-tmw.html#SP4_3">&#167;4.3</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">i</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> **</span><span class="identifier-syntax">subj1</span><span class="plain-syntax">, </span><span class="reserved-syntax">inference_subject</span><span class="plain-syntax"> **</span><span class="identifier-syntax">infs2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">i</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">i</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">family</span><span class="plain-syntax"> != </span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"not a relation inf"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_relation_inference_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">data</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">subj1</span><span class="plain-syntax">) *</span><span class="identifier-syntax">subj1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">infs2</span><span class="plain-syntax">) *</span><span class="identifier-syntax">infs2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_subjects</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">RelationInferences::get_term_specs</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">RelationInferences::get_term_specs</span></span>:<br/>Relation Subjects - <a href="4-rs.html#SP4">&#167;4</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inference</span><span class="plain-syntax"> *</span><span class="identifier-syntax">i</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> **</span><span class="identifier-syntax">val1</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> **</span><span class="identifier-syntax">spec2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">i</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">i</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">family</span><span class="plain-syntax"> != </span><span class="identifier-syntax">relation_inf</span><span class="plain-syntax">)) </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"not a relation inf"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">relation_inference_data</span><span class="plain-syntax"> *</span><span class="identifier-syntax">data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RETRIEVE_POINTER_relation_inference_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">i</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">data</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val1</span><span class="plain-syntax">) *</span><span class="identifier-syntax">val1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[0];</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">spec2</span><span class="plain-syntax">) *</span><span class="identifier-syntax">spec2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">data</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">terms_as_values</span><span class="plain-syntax">[1];</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="5-ia.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-km.html">1</a></li><li class="progresschapter"><a href="2-ins.html">2</a></li><li class="progresschapter"><a href="3-prp.html">3</a></li><li class="progresschapter"><a href="4-is.html">4</a></li><li class="progresscurrentchapter">5</li><li class="progresssection"><a href="5-inf.html">inf</a></li><li class="progresssection"><a href="5-pi.html">pi</a></li><li class="progresssection"><a href="5-ia.html">ia</a></li><li class="progresscurrent">ri</li><li class="progresssection"><a href="5-tmw.html">tmw</a></li><li class="progresssection"><a href="5-tnt.html">tnt</a></li><li class="progressnext"><a href="5-tmw.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

